<?php


abstract class BaseCustomers extends BaseObject  implements Persistent {


  const PEER = 'CustomersPeer';

	
	protected static $peer;

	
	protected $id;

	
	protected $searchkey;

	
	protected $taxid;

	
	protected $name;

	
	protected $taxcategory;

	
	protected $card;

	
	protected $maxdebt;

	
	protected $address;

	
	protected $address2;

	
	protected $postal;

	
	protected $city;

	
	protected $region;

	
	protected $country;

	
	protected $firstname;

	
	protected $lastname;

	
	protected $email;

	
	protected $phone;

	
	protected $phone2;

	
	protected $fax;

	
	protected $notes;

	
	protected $visible;

	
	protected $curdate;

	
	protected $curdebt;

	
	protected $aTaxcustcategories;

	
	protected $collReservationCustomerss;

	
	private $lastReservationCustomersCriteria = null;

	
	protected $collTicketss;

	
	private $lastTicketsCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function __construct()
	{
		parent::__construct();
		$this->applyDefaultValues();
	}

	
	public function applyDefaultValues()
	{
		$this->maxdebt = 0;
	}

	
	public function getId()
	{
		return $this->id;
	}

	
	public function getSearchkey()
	{
		return $this->searchkey;
	}

	
	public function getTaxid()
	{
		return $this->taxid;
	}

	
	public function getName()
	{
		return $this->name;
	}

	
	public function getTaxcategory()
	{
		return $this->taxcategory;
	}

	
	public function getCard()
	{
		return $this->card;
	}

	
	public function getMaxdebt()
	{
		return $this->maxdebt;
	}

	
	public function getAddress()
	{
		return $this->address;
	}

	
	public function getAddress2()
	{
		return $this->address2;
	}

	
	public function getPostal()
	{
		return $this->postal;
	}

	
	public function getCity()
	{
		return $this->city;
	}

	
	public function getRegion()
	{
		return $this->region;
	}

	
	public function getCountry()
	{
		return $this->country;
	}

	
	public function getFirstname()
	{
		return $this->firstname;
	}

	
	public function getLastname()
	{
		return $this->lastname;
	}

	
	public function getEmail()
	{
		return $this->email;
	}

	
	public function getPhone()
	{
		return $this->phone;
	}

	
	public function getPhone2()
	{
		return $this->phone2;
	}

	
	public function getFax()
	{
		return $this->fax;
	}

	
	public function getNotes()
	{
		return $this->notes;
	}

	
	public function getVisible()
	{
		return $this->visible;
	}

	
	public function getCurdate($format = 'Y-m-d H:i:s')
	{
		if ($this->curdate === null) {
			return null;
		}


		if ($this->curdate === '0000-00-00 00:00:00') {
									return null;
		} else {
			try {
				$dt = new DateTime($this->curdate);
			} catch (Exception $x) {
				throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->curdate, true), $x);
			}
		}

		if ($format === null) {
						return $dt;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $dt->format('U'));
		} else {
			return $dt->format($format);
		}
	}

	
	public function getCurdebt()
	{
		return $this->curdebt;
	}

	
	public function setId($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = CustomersPeer::ID;
		}

		return $this;
	} 
	
	public function setSearchkey($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->searchkey !== $v) {
			$this->searchkey = $v;
			$this->modifiedColumns[] = CustomersPeer::SEARCHKEY;
		}

		return $this;
	} 
	
	public function setTaxid($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->taxid !== $v) {
			$this->taxid = $v;
			$this->modifiedColumns[] = CustomersPeer::TAXID;
		}

		return $this;
	} 
	
	public function setName($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = CustomersPeer::NAME;
		}

		return $this;
	} 
	
	public function setTaxcategory($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->taxcategory !== $v) {
			$this->taxcategory = $v;
			$this->modifiedColumns[] = CustomersPeer::TAXCATEGORY;
		}

		if ($this->aTaxcustcategories !== null && $this->aTaxcustcategories->getId() !== $v) {
			$this->aTaxcustcategories = null;
		}

		return $this;
	} 
	
	public function setCard($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->card !== $v) {
			$this->card = $v;
			$this->modifiedColumns[] = CustomersPeer::CARD;
		}

		return $this;
	} 
	
	public function setMaxdebt($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->maxdebt !== $v || $v === 0) {
			$this->maxdebt = $v;
			$this->modifiedColumns[] = CustomersPeer::MAXDEBT;
		}

		return $this;
	} 
	
	public function setAddress($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->address !== $v) {
			$this->address = $v;
			$this->modifiedColumns[] = CustomersPeer::ADDRESS;
		}

		return $this;
	} 
	
	public function setAddress2($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->address2 !== $v) {
			$this->address2 = $v;
			$this->modifiedColumns[] = CustomersPeer::ADDRESS2;
		}

		return $this;
	} 
	
	public function setPostal($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->postal !== $v) {
			$this->postal = $v;
			$this->modifiedColumns[] = CustomersPeer::POSTAL;
		}

		return $this;
	} 
	
	public function setCity($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->city !== $v) {
			$this->city = $v;
			$this->modifiedColumns[] = CustomersPeer::CITY;
		}

		return $this;
	} 
	
	public function setRegion($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->region !== $v) {
			$this->region = $v;
			$this->modifiedColumns[] = CustomersPeer::REGION;
		}

		return $this;
	} 
	
	public function setCountry($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->country !== $v) {
			$this->country = $v;
			$this->modifiedColumns[] = CustomersPeer::COUNTRY;
		}

		return $this;
	} 
	
	public function setFirstname($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->firstname !== $v) {
			$this->firstname = $v;
			$this->modifiedColumns[] = CustomersPeer::FIRSTNAME;
		}

		return $this;
	} 
	
	public function setLastname($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->lastname !== $v) {
			$this->lastname = $v;
			$this->modifiedColumns[] = CustomersPeer::LASTNAME;
		}

		return $this;
	} 
	
	public function setEmail($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = CustomersPeer::EMAIL;
		}

		return $this;
	} 
	
	public function setPhone($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->phone !== $v) {
			$this->phone = $v;
			$this->modifiedColumns[] = CustomersPeer::PHONE;
		}

		return $this;
	} 
	
	public function setPhone2($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->phone2 !== $v) {
			$this->phone2 = $v;
			$this->modifiedColumns[] = CustomersPeer::PHONE2;
		}

		return $this;
	} 
	
	public function setFax($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->fax !== $v) {
			$this->fax = $v;
			$this->modifiedColumns[] = CustomersPeer::FAX;
		}

		return $this;
	} 
	
	public function setNotes($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->notes !== $v) {
			$this->notes = $v;
			$this->modifiedColumns[] = CustomersPeer::NOTES;
		}

		return $this;
	} 
	
	public function setVisible($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->visible !== $v) {
			$this->visible = $v;
			$this->modifiedColumns[] = CustomersPeer::VISIBLE;
		}

		return $this;
	} 
	
	public function setCurdate($v)
	{
						if ($v === null || $v === '') {
			$dt = null;
		} elseif ($v instanceof DateTime) {
			$dt = $v;
		} else {
									try {
				if (is_numeric($v)) { 					$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
															$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
				} else {
					$dt = new DateTime($v);
				}
			} catch (Exception $x) {
				throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
			}
		}

		if ( $this->curdate !== null || $dt !== null ) {
			
			$currNorm = ($this->curdate !== null && $tmpDt = new DateTime($this->curdate)) ? $tmpDt->format('Y-m-d H:i:s') : null;
			$newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;

			if ( ($currNorm !== $newNorm) 					)
			{
				$this->curdate = ($dt ? $dt->format('Y-m-d H:i:s') : null);
				$this->modifiedColumns[] = CustomersPeer::CURDATE;
			}
		} 
		return $this;
	} 
	
	public function setCurdebt($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->curdebt !== $v) {
			$this->curdebt = $v;
			$this->modifiedColumns[] = CustomersPeer::CURDEBT;
		}

		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array(CustomersPeer::MAXDEBT))) {
				return false;
			}

			if ($this->maxdebt !== 0) {
				return false;
			}

				return true;
	} 
	
	public function hydrate($row, $startcol = 0, $rehydrate = false)
	{
		try {

			$this->id = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
			$this->searchkey = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->taxid = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->name = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->taxcategory = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->card = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
			$this->maxdebt = ($row[$startcol + 6] !== null) ? (double) $row[$startcol + 6] : null;
			$this->address = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
			$this->address2 = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->postal = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
			$this->city = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
			$this->region = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
			$this->country = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
			$this->firstname = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
			$this->lastname = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null;
			$this->email = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
			$this->phone = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
			$this->phone2 = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null;
			$this->fax = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null;
			$this->notes = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null;
			$this->visible = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null;
			$this->curdate = ($row[$startcol + 21] !== null) ? (string) $row[$startcol + 21] : null;
			$this->curdebt = ($row[$startcol + 22] !== null) ? (double) $row[$startcol + 22] : null;
			$this->resetModified();

			$this->setNew(false);

			if ($rehydrate) {
				$this->ensureConsistency();
			}

						return $startcol + 23; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Customers object", $e);
		}
	}

	
	public function ensureConsistency()
	{

		if ($this->aTaxcustcategories !== null && $this->taxcategory !== $this->aTaxcustcategories->getId()) {
			$this->aTaxcustcategories = null;
		}
	} 
	
	public function reload($deep = false, PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("Cannot reload a deleted object.");
		}

		if ($this->isNew()) {
			throw new PropelException("Cannot reload an unsaved object.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CustomersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

				
		$stmt = CustomersPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
		$row = $stmt->fetch(PDO::FETCH_NUM);
		$stmt->closeCursor();
		if (!$row) {
			throw new PropelException('Cannot find matching row in the database to reload object values.');
		}
		$this->hydrate($row, 0, true); 
		if ($deep) {  
			$this->aTaxcustcategories = null;
			$this->collReservationCustomerss = null;
			$this->lastReservationCustomersCriteria = null;

			$this->collTicketss = null;
			$this->lastTicketsCriteria = null;

		} 	}

	
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CustomersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			CustomersPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	public function save(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CustomersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			CustomersPeer::addInstanceToPool($this);
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	protected function doSave(PropelPDO $con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;

												
			if ($this->aTaxcustcategories !== null) {
				if ($this->aTaxcustcategories->isModified() || $this->aTaxcustcategories->isNew()) {
					$affectedRows += $this->aTaxcustcategories->save($con);
				}
				$this->setTaxcustcategories($this->aTaxcustcategories);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = CustomersPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += CustomersPeer::doUpdate($this, $con);
				}

				$this->resetModified(); 			}

			if ($this->collReservationCustomerss !== null) {
				foreach ($this->collReservationCustomerss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTicketss !== null) {
				foreach ($this->collTicketss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;

		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aTaxcustcategories !== null) {
				if (!$this->aTaxcustcategories->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTaxcustcategories->getValidationFailures());
				}
			}


			if (($retval = CustomersPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collReservationCustomerss !== null) {
					foreach ($this->collReservationCustomerss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTicketss !== null) {
					foreach ($this->collTicketss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = CustomersPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getSearchkey();
				break;
			case 2:
				return $this->getTaxid();
				break;
			case 3:
				return $this->getName();
				break;
			case 4:
				return $this->getTaxcategory();
				break;
			case 5:
				return $this->getCard();
				break;
			case 6:
				return $this->getMaxdebt();
				break;
			case 7:
				return $this->getAddress();
				break;
			case 8:
				return $this->getAddress2();
				break;
			case 9:
				return $this->getPostal();
				break;
			case 10:
				return $this->getCity();
				break;
			case 11:
				return $this->getRegion();
				break;
			case 12:
				return $this->getCountry();
				break;
			case 13:
				return $this->getFirstname();
				break;
			case 14:
				return $this->getLastname();
				break;
			case 15:
				return $this->getEmail();
				break;
			case 16:
				return $this->getPhone();
				break;
			case 17:
				return $this->getPhone2();
				break;
			case 18:
				return $this->getFax();
				break;
			case 19:
				return $this->getNotes();
				break;
			case 20:
				return $this->getVisible();
				break;
			case 21:
				return $this->getCurdate();
				break;
			case 22:
				return $this->getCurdebt();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = CustomersPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getSearchkey(),
			$keys[2] => $this->getTaxid(),
			$keys[3] => $this->getName(),
			$keys[4] => $this->getTaxcategory(),
			$keys[5] => $this->getCard(),
			$keys[6] => $this->getMaxdebt(),
			$keys[7] => $this->getAddress(),
			$keys[8] => $this->getAddress2(),
			$keys[9] => $this->getPostal(),
			$keys[10] => $this->getCity(),
			$keys[11] => $this->getRegion(),
			$keys[12] => $this->getCountry(),
			$keys[13] => $this->getFirstname(),
			$keys[14] => $this->getLastname(),
			$keys[15] => $this->getEmail(),
			$keys[16] => $this->getPhone(),
			$keys[17] => $this->getPhone2(),
			$keys[18] => $this->getFax(),
			$keys[19] => $this->getNotes(),
			$keys[20] => $this->getVisible(),
			$keys[21] => $this->getCurdate(),
			$keys[22] => $this->getCurdebt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = CustomersPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setSearchkey($value);
				break;
			case 2:
				$this->setTaxid($value);
				break;
			case 3:
				$this->setName($value);
				break;
			case 4:
				$this->setTaxcategory($value);
				break;
			case 5:
				$this->setCard($value);
				break;
			case 6:
				$this->setMaxdebt($value);
				break;
			case 7:
				$this->setAddress($value);
				break;
			case 8:
				$this->setAddress2($value);
				break;
			case 9:
				$this->setPostal($value);
				break;
			case 10:
				$this->setCity($value);
				break;
			case 11:
				$this->setRegion($value);
				break;
			case 12:
				$this->setCountry($value);
				break;
			case 13:
				$this->setFirstname($value);
				break;
			case 14:
				$this->setLastname($value);
				break;
			case 15:
				$this->setEmail($value);
				break;
			case 16:
				$this->setPhone($value);
				break;
			case 17:
				$this->setPhone2($value);
				break;
			case 18:
				$this->setFax($value);
				break;
			case 19:
				$this->setNotes($value);
				break;
			case 20:
				$this->setVisible($value);
				break;
			case 21:
				$this->setCurdate($value);
				break;
			case 22:
				$this->setCurdebt($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = CustomersPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setSearchkey($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setTaxid($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setName($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setTaxcategory($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setCard($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setMaxdebt($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setAddress($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setAddress2($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setPostal($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setCity($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setRegion($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setCountry($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setFirstname($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setLastname($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setEmail($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setPhone($arr[$keys[16]]);
		if (array_key_exists($keys[17], $arr)) $this->setPhone2($arr[$keys[17]]);
		if (array_key_exists($keys[18], $arr)) $this->setFax($arr[$keys[18]]);
		if (array_key_exists($keys[19], $arr)) $this->setNotes($arr[$keys[19]]);
		if (array_key_exists($keys[20], $arr)) $this->setVisible($arr[$keys[20]]);
		if (array_key_exists($keys[21], $arr)) $this->setCurdate($arr[$keys[21]]);
		if (array_key_exists($keys[22], $arr)) $this->setCurdebt($arr[$keys[22]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(CustomersPeer::DATABASE_NAME);

		if ($this->isColumnModified(CustomersPeer::ID)) $criteria->add(CustomersPeer::ID, $this->id);
		if ($this->isColumnModified(CustomersPeer::SEARCHKEY)) $criteria->add(CustomersPeer::SEARCHKEY, $this->searchkey);
		if ($this->isColumnModified(CustomersPeer::TAXID)) $criteria->add(CustomersPeer::TAXID, $this->taxid);
		if ($this->isColumnModified(CustomersPeer::NAME)) $criteria->add(CustomersPeer::NAME, $this->name);
		if ($this->isColumnModified(CustomersPeer::TAXCATEGORY)) $criteria->add(CustomersPeer::TAXCATEGORY, $this->taxcategory);
		if ($this->isColumnModified(CustomersPeer::CARD)) $criteria->add(CustomersPeer::CARD, $this->card);
		if ($this->isColumnModified(CustomersPeer::MAXDEBT)) $criteria->add(CustomersPeer::MAXDEBT, $this->maxdebt);
		if ($this->isColumnModified(CustomersPeer::ADDRESS)) $criteria->add(CustomersPeer::ADDRESS, $this->address);
		if ($this->isColumnModified(CustomersPeer::ADDRESS2)) $criteria->add(CustomersPeer::ADDRESS2, $this->address2);
		if ($this->isColumnModified(CustomersPeer::POSTAL)) $criteria->add(CustomersPeer::POSTAL, $this->postal);
		if ($this->isColumnModified(CustomersPeer::CITY)) $criteria->add(CustomersPeer::CITY, $this->city);
		if ($this->isColumnModified(CustomersPeer::REGION)) $criteria->add(CustomersPeer::REGION, $this->region);
		if ($this->isColumnModified(CustomersPeer::COUNTRY)) $criteria->add(CustomersPeer::COUNTRY, $this->country);
		if ($this->isColumnModified(CustomersPeer::FIRSTNAME)) $criteria->add(CustomersPeer::FIRSTNAME, $this->firstname);
		if ($this->isColumnModified(CustomersPeer::LASTNAME)) $criteria->add(CustomersPeer::LASTNAME, $this->lastname);
		if ($this->isColumnModified(CustomersPeer::EMAIL)) $criteria->add(CustomersPeer::EMAIL, $this->email);
		if ($this->isColumnModified(CustomersPeer::PHONE)) $criteria->add(CustomersPeer::PHONE, $this->phone);
		if ($this->isColumnModified(CustomersPeer::PHONE2)) $criteria->add(CustomersPeer::PHONE2, $this->phone2);
		if ($this->isColumnModified(CustomersPeer::FAX)) $criteria->add(CustomersPeer::FAX, $this->fax);
		if ($this->isColumnModified(CustomersPeer::NOTES)) $criteria->add(CustomersPeer::NOTES, $this->notes);
		if ($this->isColumnModified(CustomersPeer::VISIBLE)) $criteria->add(CustomersPeer::VISIBLE, $this->visible);
		if ($this->isColumnModified(CustomersPeer::CURDATE)) $criteria->add(CustomersPeer::CURDATE, $this->curdate);
		if ($this->isColumnModified(CustomersPeer::CURDEBT)) $criteria->add(CustomersPeer::CURDEBT, $this->curdebt);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(CustomersPeer::DATABASE_NAME);

		$criteria->add(CustomersPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setId($this->id);

		$copyObj->setSearchkey($this->searchkey);

		$copyObj->setTaxid($this->taxid);

		$copyObj->setName($this->name);

		$copyObj->setTaxcategory($this->taxcategory);

		$copyObj->setCard($this->card);

		$copyObj->setMaxdebt($this->maxdebt);

		$copyObj->setAddress($this->address);

		$copyObj->setAddress2($this->address2);

		$copyObj->setPostal($this->postal);

		$copyObj->setCity($this->city);

		$copyObj->setRegion($this->region);

		$copyObj->setCountry($this->country);

		$copyObj->setFirstname($this->firstname);

		$copyObj->setLastname($this->lastname);

		$copyObj->setEmail($this->email);

		$copyObj->setPhone($this->phone);

		$copyObj->setPhone2($this->phone2);

		$copyObj->setFax($this->fax);

		$copyObj->setNotes($this->notes);

		$copyObj->setVisible($this->visible);

		$copyObj->setCurdate($this->curdate);

		$copyObj->setCurdebt($this->curdebt);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach ($this->getReservationCustomerss() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addReservationCustomers($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getTicketss() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTickets($relObj->copy($deepCopy));
				}
			}

		} 

		$copyObj->setNew(true);

	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new CustomersPeer();
		}
		return self::$peer;
	}

	
	public function setTaxcustcategories(Taxcustcategories $v = null)
	{
		if ($v === null) {
			$this->setTaxcategory(NULL);
		} else {
			$this->setTaxcategory($v->getId());
		}

		$this->aTaxcustcategories = $v;

						if ($v !== null) {
			$v->addCustomers($this);
		}

		return $this;
	}


	
	public function getTaxcustcategories(PropelPDO $con = null)
	{
		if ($this->aTaxcustcategories === null && (($this->taxcategory !== "" && $this->taxcategory !== null))) {
			$c = new Criteria(TaxcustcategoriesPeer::DATABASE_NAME);
			$c->add(TaxcustcategoriesPeer::ID, $this->taxcategory);
			$this->aTaxcustcategories = TaxcustcategoriesPeer::doSelectOne($c, $con);
			
		}
		return $this->aTaxcustcategories;
	}

	
	public function clearReservationCustomerss()
	{
		$this->collReservationCustomerss = null; 	}

	
	public function initReservationCustomerss()
	{
		$this->collReservationCustomerss = array();
	}

	
	public function getReservationCustomerss($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collReservationCustomerss === null) {
			if ($this->isNew()) {
			   $this->collReservationCustomerss = array();
			} else {

				$criteria->add(ReservationCustomersPeer::CUSTOMER, $this->id);

				ReservationCustomersPeer::addSelectColumns($criteria);
				$this->collReservationCustomerss = ReservationCustomersPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(ReservationCustomersPeer::CUSTOMER, $this->id);

				ReservationCustomersPeer::addSelectColumns($criteria);
				if (!isset($this->lastReservationCustomersCriteria) || !$this->lastReservationCustomersCriteria->equals($criteria)) {
					$this->collReservationCustomerss = ReservationCustomersPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastReservationCustomersCriteria = $criteria;
		return $this->collReservationCustomerss;
	}

	
	public function countReservationCustomerss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collReservationCustomerss === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(ReservationCustomersPeer::CUSTOMER, $this->id);

				$count = ReservationCustomersPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(ReservationCustomersPeer::CUSTOMER, $this->id);

				if (!isset($this->lastReservationCustomersCriteria) || !$this->lastReservationCustomersCriteria->equals($criteria)) {
					$count = ReservationCustomersPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collReservationCustomerss);
				}
			} else {
				$count = count($this->collReservationCustomerss);
			}
		}
		$this->lastReservationCustomersCriteria = $criteria;
		return $count;
	}

	
	public function addReservationCustomers(ReservationCustomers $l)
	{
		if ($this->collReservationCustomerss === null) {
			$this->initReservationCustomerss();
		}
		if (!in_array($l, $this->collReservationCustomerss, true)) { 			array_push($this->collReservationCustomerss, $l);
			$l->setCustomers($this);
		}
	}


	
	public function getReservationCustomerssJoinReservations($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collReservationCustomerss === null) {
			if ($this->isNew()) {
				$this->collReservationCustomerss = array();
			} else {

				$criteria->add(ReservationCustomersPeer::CUSTOMER, $this->id);

				$this->collReservationCustomerss = ReservationCustomersPeer::doSelectJoinReservations($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(ReservationCustomersPeer::CUSTOMER, $this->id);

			if (!isset($this->lastReservationCustomersCriteria) || !$this->lastReservationCustomersCriteria->equals($criteria)) {
				$this->collReservationCustomerss = ReservationCustomersPeer::doSelectJoinReservations($criteria, $con, $join_behavior);
			}
		}
		$this->lastReservationCustomersCriteria = $criteria;

		return $this->collReservationCustomerss;
	}

	
	public function clearTicketss()
	{
		$this->collTicketss = null; 	}

	
	public function initTicketss()
	{
		$this->collTicketss = array();
	}

	
	public function getTicketss($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTicketss === null) {
			if ($this->isNew()) {
			   $this->collTicketss = array();
			} else {

				$criteria->add(TicketsPeer::CUSTOMER, $this->id);

				TicketsPeer::addSelectColumns($criteria);
				$this->collTicketss = TicketsPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TicketsPeer::CUSTOMER, $this->id);

				TicketsPeer::addSelectColumns($criteria);
				if (!isset($this->lastTicketsCriteria) || !$this->lastTicketsCriteria->equals($criteria)) {
					$this->collTicketss = TicketsPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTicketsCriteria = $criteria;
		return $this->collTicketss;
	}

	
	public function countTicketss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTicketss === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TicketsPeer::CUSTOMER, $this->id);

				$count = TicketsPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TicketsPeer::CUSTOMER, $this->id);

				if (!isset($this->lastTicketsCriteria) || !$this->lastTicketsCriteria->equals($criteria)) {
					$count = TicketsPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTicketss);
				}
			} else {
				$count = count($this->collTicketss);
			}
		}
		$this->lastTicketsCriteria = $criteria;
		return $count;
	}

	
	public function addTickets(Tickets $l)
	{
		if ($this->collTicketss === null) {
			$this->initTicketss();
		}
		if (!in_array($l, $this->collTicketss, true)) { 			array_push($this->collTicketss, $l);
			$l->setCustomers($this);
		}
	}


	
	public function getTicketssJoinReceipts($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTicketss === null) {
			if ($this->isNew()) {
				$this->collTicketss = array();
			} else {

				$criteria->add(TicketsPeer::CUSTOMER, $this->id);

				$this->collTicketss = TicketsPeer::doSelectJoinReceipts($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TicketsPeer::CUSTOMER, $this->id);

			if (!isset($this->lastTicketsCriteria) || !$this->lastTicketsCriteria->equals($criteria)) {
				$this->collTicketss = TicketsPeer::doSelectJoinReceipts($criteria, $con, $join_behavior);
			}
		}
		$this->lastTicketsCriteria = $criteria;

		return $this->collTicketss;
	}


	
	public function getTicketssJoinPeople($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(CustomersPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTicketss === null) {
			if ($this->isNew()) {
				$this->collTicketss = array();
			} else {

				$criteria->add(TicketsPeer::CUSTOMER, $this->id);

				$this->collTicketss = TicketsPeer::doSelectJoinPeople($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TicketsPeer::CUSTOMER, $this->id);

			if (!isset($this->lastTicketsCriteria) || !$this->lastTicketsCriteria->equals($criteria)) {
				$this->collTicketss = TicketsPeer::doSelectJoinPeople($criteria, $con, $join_behavior);
			}
		}
		$this->lastTicketsCriteria = $criteria;

		return $this->collTicketss;
	}

	
	public function clearAllReferences($deep = false)
	{
		if ($deep) {
			if ($this->collReservationCustomerss) {
				foreach ((array) $this->collReservationCustomerss as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collTicketss) {
				foreach ((array) $this->collTicketss as $o) {
					$o->clearAllReferences($deep);
				}
			}
		} 
		$this->collReservationCustomerss = null;
		$this->collTicketss = null;
			$this->aTaxcustcategories = null;
	}

} 